﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using a001.Models;

namespace a001.Controllers
{
    public class HomeController : Controller
    {
        Models.Aroots aroots=new Aroots();
        /// <summary>
        /// 执行一个复制方法
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            string sourceFileName = @"D:\cSharp\20201009发哥实例集\img";
            string destinationFileName = @"D:\";
            //string sourceFileName = @"\img";
            //string destinationFileName = @"D:\";
            aroots.CopyFile(
             sourceFileName,
             destinationFileName
             );
            return Content("当你看到这个页面，系统执行了一个复制动作，其方法是:@string sourceFileName \n成功执行复制动作");
        }

        public IActionResult Privacy()
        {
            return View();
        }

        //输出css文件到页面
        public ActionResult Fn()
        {
            return File("/css/site.css"//文件路径
            , "text/css"//文件类型
            );
        }

        //输出jpg文件到页面-整个页面渲染为图片
        public ActionResult Fn2()
        {
            return File("/css/71-4-302茜茜2.jpg"//文件路径
            , "image/jpeg"//文件类型
            );
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
